'''
Created on 2010-12-11

@author: Administrator
@summary: 1. How to Create toolBar, and Add Tools
          2. How to Create MenuBar, And Add Menu, Add Menu Options
          3. How to Create StatusBar
          4. Important: Tool Bar, Menu Bar, Status Bar, are Members of Frame, 
             Not Panel
          5. How to Bind Event To Menu, Toolbar 
          6. How to Use Dialog, include create, show, distroy
'''

import wx
import images

class ToolBarFrame(wx.Frame):
  def __init__(self, parent, id):
    wx.Frame.__init__(self, parent, id, 'Toolbars', size=(300, 200))
    panel = wx.Panel(self)
    panel.SetBackgroundColour('White')
    statusBar = self.CreateStatusBar()
    # Create Toolbar
    toolBar = self.CreateToolBar()
    textEntryDialogDemo = toolBar.AddSimpleTool(wx.NewId(), 
                                                images.getPyBitmap(), "New", 
                                                "Long Help For 'New'")
    toolBar.Realize()
    
    self.Bind(wx.EVT_TOOL, self.ShowTextEntryDialog, textEntryDialogDemo)
    
    # Create Menu Bar
    menuBar = wx.MenuBar()
    menu1 = wx.Menu()
    m_opt1 = menu1.Append(wx.NewId(), "Message Dialog", "Open Message Dialog")
    menuBar.Append(menu1, "File")
    self.Bind(wx.EVT_MENU, self.ShowMessageDialog, m_opt1)
    
    menu2 = wx.Menu()
    
    # Create Menu Option
    menu2.Append(wx.NewId(), "Copy", "Copy in status bar")
    menu2.Append(wx.NewId(), "Cut", "")
    menu2.Append(wx.NewId(), "Paste", "")
    menu2.AppendSeparator()
    menu2.Append(wx.NewId(), "Options", "Display Options")
    menuBar.Append(menu2, "Edit")
    
    menu3 = wx.Menu()
    ssdm = menu3.Append(wx.NewId(), "Click", "Open Single Select Dialog")
    menuBar.Append(menu3, "&Click Me")
    
    self.Bind(wx.EVT_MENU, self.ShowSingleChoiceDialog, ssdm)
    
    self.SetMenuBar(menuBar)
    
  def ShowMessageDialog(self, event):
    dlg = wx.MessageDialog(None, 'Is this the coolest thing ever!',
                           'MessageDialog', wx.YES_NO | wx.ICON_QUESTION)
    result = dlg.ShowModal()
    dlg.Destroy()
    
  def ShowTextEntryDialog(self, event):
    dlg = wx.TextEntryDialog(None, "Who is buried in Grant's tomb?", 
                             'A Question', 'Cary Grant')
    if dlg.ShowModal() == wx.ID_OK:
      response = dlg.GetValue()
  
  def ShowSingleChoiceDialog(self, event):
    dlg = wx.SingleChoiceDialog(None, 'What verion of Python are you using?',
                                'Single Choice',['1.5.2', '2.0', '2.1.3', '2.2',
                                                 '2.3.1'])
    if dlg.ShowModal() == wx.ID_OK:
      response = dlg.GetStringSelection()
    
  
if __name__ == '__main__':
  app = wx.PySimpleApp()
  frame = ToolBarFrame(parent=None, id=-1)
  frame.Show()
  app.MainLoop()
  
